<%@ page contentType="text/html;charset=utf-8" pageEncoding="UTF-8"%>
<%@include file="/common/common.jsp" %>
<%@ taglib uri="/WEB-INF/c.tld" prefix="c"%>
<%@page import="com.jmx.yp.common.SysConstants"%>

<html>
	<head>
		<title>员工管理_修改员工</title>
		<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/skin.css">
		<link href="${pageContext.request.contextPath}/css/jquery.alerts.css" rel="stylesheet" type="text/css" media="screen">		
		<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery/jquery-1.4.2.min.js"></script>
		<script src="${pageContext.request.contextPath}/js/jquery/jquery.ui.draggable.js" type="text/javascript"></script>
		<script src="${pageContext.request.contextPath}/js/jquery/jquery.alerts.js" type="text/javascript"></script>
		<script src="${pageContext.request.contextPath}/js/tools.js" type="text/javascript"></script>
		<script src="${pageContext.request.contextPath}/js/modal/popup.js"  type="text/javascript"></script>
		<script src="${pageContext.request.contextPath}/js/modal/popupclass.js"  type="text/javascript"></script>
		<style type="text/css">
			<!--
			body {
				margin-left: 0px;
				margin-top: 0px;
				margin-right: 0px;
				margin-bottom: 0px;
			}
			.STYLE1 {font-size: 12px}
			.STYLE3 {font-size: 12px; font-weight: bold; }
			.STYLE4 {
				color: #03515d;
				font-size: 12px;
			}
			-->
		</style>
		<script type="text/javascript">
			var nameFirst,nameLast,roleId,sex,birthYear,birthMonty,birthDay,education,serialid;
			var postalcode,address,email,telCn,telArea,tel,qicq,msn,yahoomsg,skpye,gtalk,remark;
			
			function onUpdate(){
				//验证
				if(employeeForm.pass.value.trim() != ""){
					if(!checkedTextArea(employeeForm.pass.value.trim(), 50, "密码")){
						employeeForm.pass.focus();
						return false;
					}else{
						if(employeeForm.comfirmPass.value.trim() == ""){
							jAlert('warning', '确认密码不能为空!', '操作警告');
							employeeForm.comfirmPass.focus();
							return false;
						}else{
							if(employeeForm.comfirmPass.value.trim() != employeeForm.pass.value.trim()){
								jAlert('warning', '密码与确认密码不相同，请重新输入!', '操作警告');
								return false;
							}
						}
					}
				}

				if(employeeForm.nameFirst.value.trim() == ""){
					jAlert('warning', '中文姓不能为空!', '操作警告');
					employeeForm.nameFirst.focus();
					return false;
				}else{
					if(!(checkedTextArea(employeeForm.nameFirst.value.trim(), 50, "中文姓"))){
						employeeForm.nameFirst.focus();
						return false;
					}
				}

				if(employeeForm.nameLast.value.trim() == ""){
					jAlert('warning', '中文名不能为空!', '操作警告');
					employeeForm.nameLast.focus();
					return false;
				}else{
					if(!(checkedTextArea(employeeForm.nameLast.value.trim(), 50, "中文名"))){
						employeeForm.nameLast.focus();
						return false;
					}
				}

				if(employeeForm.postalcode.value.trim() != "" ){
					if(!(checkedTextArea(employeeForm.postalcode.value.trim(), 10, "邮政编码"))){						
						employeeForm.postalcode.focus();
						return false;
					}
				}

				if(employeeForm.address.value.trim() != "" ){
					if(!(checkedTextArea(employeeForm.address.value.trim(), 500, "通信地址"))){						
						employeeForm.address.focus();
						return false;
					}
				}

				if(employeeForm.email.value.trim() != "" ){
					if(!(checkedTextArea(employeeForm.email.value.trim(), 50, "常用邮箱"))){						
						employeeForm.email.focus();
						return false;
					}else{
						if(!(isEmail(employeeForm.email.value.trim()))){
							jAlert('warning', '常用邮箱格式不正确!', '操作警告');
							employeeForm.email.focus();
							return false;
						}
					}
				}

				if(employeeForm.qicq.value.trim() != "" ){
					if(!(checkedTextArea(employeeForm.qicq.value.trim(), 50, "OICQ"))){						
						employeeForm.qicq.focus();
						return false;
					}
				}

				if(employeeForm.msn.value.trim() != "" ){
					if(!(checkedTextArea(employeeForm.msn.value.trim(), 50, "MSN"))){						
						employeeForm.msn.focus();
						return false;
					}
				}

				if(employeeForm.yahoomsg.value.trim() != "" ){
					if(!(checkedTextArea(employeeForm.yahoomsg.value.trim(), 50, "YAHOOMSG"))){						
						employeeForm.yahoomsg.focus();
						return false;
					}
				}
				
				if(employeeForm.skpye.value.trim() != "" ){
					if(!(checkedTextArea(employeeForm.skpye.value.trim(), 50, "SKPYE"))){						
						employeeForm.skpye.focus();
						return false;
					}
				}

				if(employeeForm.gtalk.value.trim() != "" ){
					if(!(checkedTextArea(employeeForm.gtalk.value.trim(), 50, "GTALK"))){						
						employeeForm.gtalk.focus();
						return false;
					}
				}
				
				if(employeeForm.remark.value.trim() != "" ){
					if(!(checkedTextArea(employeeForm.remark.value.trim(), 500, "备注"))){						
						employeeForm.remark.focus();
						return false;
					}
				}

				//alert($("input[@type=radio][name=sex][checked]").val());
				//return false;
								
				//提交
				var url = "updateEmployee.action";
				
				var params = {
						loginName:"<s:property value='loginName'/>",
						pass:$('#pass').attr('value'),
						nameFirst:$('#nameFirst').val(),
						nameLast:$('#nameLast').val(),
						roleId:$('#roleId').val(),
						sex:$("input[@type=radio][name=sex][checked]").val(),
						birthday:$('#birthYear').val() + '-' + $('#birthMonth').val() + '-' + $('#birthDay').val(),
						education:$('#education').val(),
						postalcode:$('#postalcode').val(),
						address:$('#address').val(),
						email:$('#email').val(),
						telCn:$('#telCn').val(),
						telArea:$('#telArea').val(),
						tel:$('#tel').val(),
						qicq:$('#qicq').val(),
						msn:$('#msn').val(),
						yahoomsg:$('#yahoomsg').val(),
						skpye:$('#skpye').val(),
						gtalk:$('#gtalk').val(),
						remark:$('#remark').val(),
						serialid:serialid
						};
				$.post(url, params, callback, "json");
			}

			function callback(data){				
				if(data.results == "success"){
					setProperties(data);
					onReset();
					jAlert('success', '修改员工成功!', '操作提示');
				}else
					jAlert('error', data.results, '操作提示');				
			}			

			function onReset(){
				employeeForm.pass.value = "";
				employeeForm.comfirmPass.value = "";
				employeeForm.nameFirst.value = nameFirst;
				employeeForm.nameLast.value = nameLast;
				employeeForm.roleId.value = roleId;

				for(var i = 0; i < employeeForm.sex.length; i++){
					if(employeeForm.sex[i].value == sex){
						employeeForm.sex[i].checked = true;
						break;
					}
				}
				
				employeeForm.birthMonth.value = birthMonth;
				employeeForm.birthYear.value = birthYear;
				employeeForm.birthDay.value = birthDay;
				employeeForm.education.value = education;
				employeeForm.postalcode.value = postalcode;
				employeeForm.address.value = address;
				employeeForm.email.value = email;
				employeeForm.telCn.value = telCn;
				employeeForm.telArea.value = telArea;
				employeeForm.tel.value = tel;
				employeeForm.qicq.value = qicq;
				employeeForm.msn.value = msn;
				employeeForm.yahoomsg.value = yahoomsg;
				employeeForm.skpye.value = skpye;
				employeeForm.gtalk.value = gtalk;
				employeeForm.remark.value = remark;
			}

			function onReturn(){
				location.href = "${pageContext.request.contextPath}/admin/employee/employeeList.action";
			}

			function setProperties(data){
				nameFirst = data.nameFirst;
			 	nameLast = data.nameLast;
			 	roleId = data.roleId;
			 	sex = data.sex;
			 	birthYear = data.birthday.split("-")[0];
			 	birthMonth = data.birthday.split("-")[1];
			 	birthDay = data.birthday.split("-")[2];
			 	education = data.education;
			 	postalcode = data.postalcode;
			 	address = data.address;
			 	email = data.email;
			 	telCn = data.telCn;
			 	telArea = data.telArea;
			 	tel = data.tel;
			 	qicq = data.qicq;
			 	msn = data.msn;
			 	yahoomsg = data.yahoomsg;
			 	skpye = data.skpye;
			 	gtalk = data.gtalk;
			 	remark = data.remark;
			}
			
			function init(){				
				onReset();
			}
			
		</script>
	</head>
	
	<body onload="init()">
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
			<tr>
				<td height="30" background="${pageContext.request.contextPath}/admin/images/main/tab_05.gif">
					<!-- 导航条 -->
					<table width="100%" border="0" cellspacing="0" cellpadding="0">
			      		<tr>
			        		<td width="12" height="30"><img src="${pageContext.request.contextPath}/admin/images/main/left-top-right.gif" width="12" height="30" /></td>
			       			<td>
			       				<table width="100%" border="0" cellspacing="0" cellpadding="0">
			          				<tr>
			            				<td width="46%" valign="middle">
			            					<table width="100%" border="0" cellspacing="0" cellpadding="0">
			              						<tr>
			                						<td width="5%"><div align="center"><img src="${pageContext.request.contextPath}/admin/images/main/tb.gif" width="16" height="16" /></div></td>
			                						<td width="95%" class="STYLE1"><span class="STYLE3">你当前的位置</span>：[安全中心]-[员工管理]-[修改员工]</td>
			              						</tr>
			            					</table>
			            				</td>			            				
			          				</tr>
			        			</table>
			        		</td>
			        		<td width="16"><img src="${pageContext.request.contextPath}/admin/images/main/nav-right-bg.gif" width="16" height="30" /></td>
			      		</tr>
			    	</table>
			    </td>
			  </tr>
			  <!-- 员工信息内容 -->
			  <tr>
			   <td>
			   		<table width="100%" border="0" cellspacing="0" cellpadding="0">
			      		<tr>
			        		<td width="3">&nbsp;</td>
			  	  	 		<td><table width="100%" height="30" border="0" bgcolor="b5d6e6" cellpadding="0" cellspacing="1" class="nowtable">
              						<tr>
                						<td class="left_bt2">&nbsp;&nbsp;&nbsp;&nbsp;员工基本信息</td>
              						</tr>
            		 			</table>
            	 			</td>
            	 			<td width="3" >&nbsp;</td>
            	 		</tr>
            	 	</table>
            	 </td>
			  </tr>
			  
			  <s:form name="employeeForm" id="employeeForm" action="addEmployee" method="post" namespace="/employee" >
			  <tr>
			     <td>
			   		<table width="100%" border="0" cellspacing="0" cellpadding="0">
			      		<tr>
			        		<td width="3">&nbsp;</td>
			  	  	 		<td><table width="100%" height="30" border="0" bgcolor="b5d6e6" cellpadding="0" cellspacing="0" class="nowtable">
              						 <tr>
                						<td width="20%" height="30" align="right" bgcolor="#f2f2f2" class="left_txt2" >登录帐号：</td>
                						<td width="3%" bgcolor="#f2f2f2">&nbsp;</td>
                						<td width="32%" height="30" bgcolor="#f2f2f2">
                							<input name="loginName" id="loginName" type="text" size="15" maxlength="50" readonly value="<s:property value="loginName"/>"/>
                						</td>
                						<td width="45%" height="30" bgcolor="#f2f2f2" class="left_txt"></td>
              						 </tr>
              						 <tr>
                						<td height="30" align="right" class="left_txt2">登录密码：</td>
                						<td>&nbsp;</td>
                						<td height="30"><input type="password" id="pass" name="pass" size="32" maxlength="50"/></td>
                						<td height="30" class="left_txt">（<font color="red">必填项</font>）</td>
              						</tr>
              						<tr>
                						<td width="20%" height="30" align="right" bgcolor="#f2f2f2" class="left_txt2">确认密码：</td>
                						<td width="3%" bgcolor="#f2f2f2">&nbsp;</td>
                						<td width="32%" height="30" bgcolor="#f2f2f2"><input type="password" id="comfirmPass" name="comfirmPass" size="32" maxlength="50"/></td>
                						<td width="45%" height="30" bgcolor="#f2f2f2" class="left_txt">（<font color="red">必填项</font>）</td>
              						</tr>
              						
              						 <tr>
                						<td height="30" align="right" class="left_txt2">中文姓：</td>
                						<td>&nbsp;</td>
                						<td height="30"><input type="text" id="nameFirst" name="nameFirst" size="30" maxlength="50"/></td>
                						<td height="30" class="left_txt">（<font color="red">必填项</font>）</td>
              						</tr>
              						
              						<tr>
                						<td width="20%" height="30" align="right" bgcolor="#f2f2f2" class="left_txt2">中文名：</td>
                						<td width="3%" bgcolor="#f2f2f2">&nbsp;</td>
                						<td width="32%" height="30" bgcolor="#f2f2f2"><input type="text" id="nameLast" name="nameLast" size="30" maxlength="50"/></td>
                						<td width="45%" height="30" bgcolor="#f2f2f2" class="left_txt">（<font color="red">必填项</font>）</td>
              						</tr>
              						<tr>
                						<td height="30" align="right" class="left_txt2">所属组织机构：</td>
                						<td>&nbsp;</td>
                						<td height="30">
                							<input type="text" id="groupName" name="groupName" size="30" readonly value="<s:property value="groupName"/>"/>
                							<input type="hidden" id="groupId" name="groupId" value="<s:property value="groupId"/>"/>
                						</td>
                						<td height="30" class="left_txt"></td>
              						</tr>
              						<tr>
                						<td width="20%" height="30" align="right" bgcolor="#f2f2f2" class="left_txt2">所属角色：</td>
                						<td width="3%" bgcolor="#f2f2f2">&nbsp;</td>
                						<td width="32%" height="30" bgcolor="#f2f2f2">
                							<s:select list="roleList" name="roleId" id="roleId" listKey="SERIALID" listValue="ROLE_NAME" />
                						</td>
                						<td width="45%" height="30" bgcolor="#f2f2f2" class="left_txt">（<font color="red">必填项</font>）</td>
              						</tr>
              						<tr>
                						<td height="30" align="right" class="left_txt2">性别：</td>
                						<td>&nbsp;</td>
                						<td height="30" class="left_txt2">
                							<input type="radio" name="sex" id="sex1" value="<%=SysConstants.SEX_MAN%>" checked>男士&nbsp;&nbsp;
                							<input type="radio" name="sex" id="sex2" value="<%=SysConstants.SEX_WOMAN%>" >女士
                						</td>
                						<td height="30" class="left_txt"></td>
              						</tr>
              						<tr>
                						<td width="20%" height="30" align="right" bgcolor="#f2f2f2" class="left_txt2">出生年月：</td>
                						<td width="3%" bgcolor="#f2f2f2">&nbsp;</td>
                						<td width="32%" height="30" bgcolor="#f2f2f2" class="left_txt2">
                							<select name="birthYear" id="birthYear">                								
                								<c:forEach var="i" begin="1950" end="2010" step="1">
                									<option value="${i}">${i}</option>
                								</c:forEach>                								
                							</select>
                							年
                							<select name="birthMonth" id="birthMonth">    								
                								<c:forEach var="i" begin="1" end="12" step="1">
                									<option value="${i}">${i}</option>
                								</c:forEach>                								
                							</select>
                							月
                							<select name="birthDay" id="birthDay">                								
                								<c:forEach var="i" begin="1" end="31" step="1">
                									<option value="${i}">${i}</option>
                								</c:forEach>                								
                							</select>
                							日
                						</td>
                						<td width="45%" height="30" bgcolor="#f2f2f2" class="left_txt"></td>
              						</tr>
              						<!-- 重新设置具体属性 -->
              						<tr>
                						<td height="30" align="right" class="left_txt2">最高学历：</td>
                						<td>&nbsp;</td>
                						<td height="30">
                							<s:select list="educationMap" name="education" id="education" listKey="key" listValue="value"/>
                						</td>
                						<td height="30" class="left_txt"></td>
              						</tr>
              						<tr>
                						<td width="20%" height="30" align="right" bgcolor="#f2f2f2" class="left_txt2">邮政编码：</td>
                						<td width="3%" bgcolor="#f2f2f2">&nbsp;</td>
                						<td width="32%" height="30" bgcolor="#f2f2f2"><input type="text" id=postalcode name="postalcode" size="30" maxlength="10"/></td>
                						<td width="45%" height="30" bgcolor="#f2f2f2" class="left_txt"></td>
              						</tr>
              						<tr>
                						<td height="30" align="right" class="left_txt2">通信地址：</td>
                						<td>&nbsp;</td>
                						<td height="30"><input type="text" id="address" name="address" size="30"  maxlength="500"/></td>
                						<td height="30" class="left_txt"></td>
              						</tr>
              						<tr>
                						<td width="20%" height="30" align="right" bgcolor="#f2f2f2" class="left_txt2">常用邮箱：</td>
                						<td width="3%" bgcolor="#f2f2f2">&nbsp;</td>
                						<td width="32%" height="30" bgcolor="#f2f2f2"><input type="text" id="email" name="email" size="30" maxlength="50"/></td>
                						<td width="45%" height="30" bgcolor="#f2f2f2" class="left_txt"></td>
              						</tr>
              						<tr>
                						<td height="30" align="right" class="left_txt2">联系电话：</td>
                						<td>&nbsp;</td>
                						<td height="30">
                							<input type="text" id="telCn" name="telCn" style="width:32px;" title="国家编号" maxlength="10" onkeyup="value=value.replace(/[^\d]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))" />
                							-
                							<input type="text" id="telArea" name="telArea" size="4" title="地区编号" maxlength="10" onkeyup="value=value.replace(/[^\d]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))" />
                							-
                							<input type="text" id="tel" name="tel" size="10" title="电话号码" maxlength="50" onkeyup="value=value.replace(/[^\d]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))" />
                						</td>
                						<td height="30" class="left_txt"></td>
              						</tr>
              						
              						<tr>
                						<td width="20%" height="30" align="right" bgcolor="#f2f2f2" class="left_txt2">OICQ：</td>
                						<td width="3%" bgcolor="#f2f2f2">&nbsp;</td>
                						<td width="32%" height="30" bgcolor="#f2f2f2"><input type="text" id="qicq" name="qicq" size="30" maxlength="50"/></td>
                						<td width="45%" height="30" bgcolor="#f2f2f2" class="left_txt"></td>
              						</tr>
              						<tr>
                						<td height="30" align="right" class="left_txt2">MSN：</td>
                						<td>&nbsp;</td>
                						<td height="30"><input type="text" id="msn" name="msn" size="30" maxlength="50"/></td>
                						<td height="30" class="left_txt"></td>
              						</tr>
              						<tr>
                						<td width="20%" height="30" align="right" bgcolor="#f2f2f2" class="left_txt2">YAHOOMSG：</td>
                						<td width="3%" bgcolor="#f2f2f2">&nbsp;</td>
                						<td width="32%" height="30" bgcolor="#f2f2f2"><input type="text" id="yahoomsg" name="yahoomsg" size="30" maxlength="50"/></td>
                						<td width="45%" height="30" bgcolor="#f2f2f2" class="left_txt"></td>
              						</tr>
              						<tr>
                						<td height="30" align="right" class="left_txt2">SKPYE：</td>
                						<td>&nbsp;</td>
                						<td height="30"><input type="text" id="skpye" name="skpye" size="30" maxlength="50"/></td>
                						<td height="30" class="left_txt"></td>
              						</tr>
              						<tr>
                						<td width="20%" height="30" align="right" bgcolor="#f2f2f2" class="left_txt2">GTALK：</td>
                						<td width="3%" bgcolor="#f2f2f2">&nbsp;</td>
                						<td width="32%" height="30" bgcolor="#f2f2f2"><input type="text" id="gtalk" name="gtalk" size="30" maxlength="50"/></td>
                						<td width="45%" height="30" bgcolor="#f2f2f2" class="left_txt"></td>
              						</tr>
              						<tr>
                						<td height="30" align="right" class="left_txt2">备注：</td>
                						<td>&nbsp;</td>
                						<td height="30">
                							<textarea rows="3" cols="40" id="remark" name="ramark" ></textarea>
                						</td>
                						<td height="30" class="left_txt"></td>
              						</tr>
              						
            		 			</table>
            	 			</td>
            	 			<td width="3" >&nbsp;</td>
            	 		</tr>
            	 	</table>
            	 </td>
			  </tr>
			  
			  
			  <tr>
              	  <td height="30">&nbsp;</td>
              </tr>
              <tr>
                  <td align="center">
              	      <input type=button value="&nbsp;保&nbsp;存&nbsp;" name="B1" onclick="onUpdate()" />
              		  &nbsp;&nbsp;
              		  <input type="button" value="&nbsp;重&nbsp;置&nbsp;" name="B12" onclick="onReset()"/>
              		  &nbsp;&nbsp;
              		  <input type="button" value="&nbsp;返&nbsp;回&nbsp;" name="B2" onclick="onReturn()"/>
              	  </td>
     	      </tr>
     	      <s:hidden name="employeeType" id="employeeType"/>
			 </s:form>
			 <script>
			 	nameFirst = "${nameFirst}";
			 	nameLast = "${nameLast}";
			 	roleId = "${roleId}";
			 	sex = "${sex}";
			 	birthYear = "${birthday}".split("-")[0];
			 	birthMonth = "${birthday}".split("-")[1];
			 	birthDay = "${birthday}".split("-")[2];
			 	education = "${education}";
			 	postalcode = "${postalcode}";
			 	address = "${address}";
			 	email = "${email}";
			 	telCn = "${telCn}";
			 	telArea = "${telArea}";
			 	tel = "${tel}";
			 	qicq = "${qicq}";
			 	msn = "${msn}";
			 	yahoomsg = "${yahoomsg}";
			 	skpye = "${skpye}";
			 	gtalk = "${gtalk}";
			 	remark = "${remark}";
			 	serialid = "${serialid}";
			 </script>
		</table>
	</body>
</html>